package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsBasicClientType;
import com.scau402.system.service.IWmsBasicClientTypeService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 客户类型Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/clientType")
public class WmsBasicClientTypeController extends BaseController
{
    @Autowired
    private IWmsBasicClientTypeService wmsBasicClientTypeService;

    /**
     * 查询客户类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsBasicClientType wmsBasicClientType)
    {
        startPage();
        List<WmsBasicClientType> list = wmsBasicClientTypeService.selectWmsBasicClientTypeList(wmsBasicClientType);
        return getDataTable(list);
    }

    /**
     * 导出客户类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:export')")
    @Log(title = "客户类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsBasicClientType wmsBasicClientType)
    {
        List<WmsBasicClientType> list = wmsBasicClientTypeService.selectWmsBasicClientTypeList(wmsBasicClientType);
        ExcelUtil<WmsBasicClientType> util = new ExcelUtil<WmsBasicClientType>(WmsBasicClientType.class);
        util.exportExcel(response, list, "客户类型数据");
    }

    /**
     * 获取客户类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:query')")
    @GetMapping(value = "/{clientType}")
    public AjaxResult getInfo(@PathVariable("clientType") String clientType)
    {
        return success(wmsBasicClientTypeService.selectWmsBasicClientTypeByClientType(clientType));
    }

    /**
     * 新增客户类型
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:add')")
    @Log(title = "客户类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsBasicClientType wmsBasicClientType)
    {
        return toAjax(wmsBasicClientTypeService.insertWmsBasicClientType(wmsBasicClientType));
    }

    /**
     * 修改客户类型
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:edit')")
    @Log(title = "客户类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsBasicClientType wmsBasicClientType)
    {
        return toAjax(wmsBasicClientTypeService.updateWmsBasicClientType(wmsBasicClientType));
    }

    /**
     * 删除客户类型
     */
    @PreAuthorize("@ss.hasPermi('system:clientType:remove')")
    @Log(title = "客户类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{clientTypes}")
    public AjaxResult remove(@PathVariable String[] clientTypes)
    {
        return toAjax(wmsBasicClientTypeService.deleteWmsBasicClientTypeByClientTypes(clientTypes));
    }
}
